# -*- mode:bash -*-

test_read_uninitailized() {
    assert_equal 0 $(memory_read 0)
    assert_equal 0 $(memory_read 4095)
}


test_read_write() {
    memory_write 1 0; assert_equal 1 $(memory_read 0)
    memory_write 4095 0; assert_equal 4095 $(memory_read 0)
    memory_write 2 4095; assert_equal 2 $(memory_read 4095)
}

test_memory_read_limits() {
    assert_not_null "$(memory_read -1 2>&1 1>/dev/null)"
    assert_not_null "$(memory_read 4096 2>&1 1>/dev/null)"
}

test_memory_write_limits() {
    assert_not_null "$(memory_write -1 0 2>&1 1>/dev/null)"
    assert_not_null "$(memory_write 4096 0 2>&1 1>/dev/null)"
    assert_not_null "$(memory_write 0 -1 2>&1 1>/dev/null)"
    assert_not_null "$(memory_write 0 4096 2>&1 1>/dev/null)"
}

source memory.sh